/* name: bird
 * author: 5ab
 * created at: 2024-06-04
 */
#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(), (x).end()
#define ssz(x) (int((x).size()))

auto chmax = [](auto& x, auto y) { if (x < y) x = y; };
auto chmin = [](auto& x, auto y) { if (y < x) x = y; };

using ll = long long;
const int N = 1e5;

int hd[N], des[N * 2], nxt[N * 2], siz[N], ec = 0;

void add(int s, int t)
{
	des[ec] = t;
	nxt[ec] = hd[s];
	hd[s] = ec++;
}

multiset<pair<int, int>, greater<>> sl[N];
void dfs(int id, int fa)
{
	siz[id] = 1;
	int mxs = -1, mxp = -1;
	for (int p = hd[id], dst; p != -1; p = nxt[p])
	{
		dst = des[p];
		if (dst != fa)
		{
			dfs(dst, id);
			siz[id] += siz[dst];
			if (siz[dst] > mxs)
				mxs = siz[dst], mxp = dst;
		}
	}
	if (mxp != -1)
		sl[id].swap(sl[mxp]);
	for (int p = hd[id], dst; p != -1; p = nxt[p])
	{
		dst = des[p];
		if (dst != fa && dst != mxp)
		{
			for (auto x : sl[dst])
				sl[id].insert(x);
			sl[dst].clear();
		}
	}
	if (ssz(sl[id]) == 0)
		sl[id].emplace(1, 0);
	else if (ssz(sl[id]) == 1)
	{
		auto [x, xc] = *sl[id].begin();
		sl[id].clear();
		sl[id].emplace(x, xc + 1);
		sl[id].emplace(1, -1);
	}
	else
	{
		auto [x, xc] = *sl[id].begin(); sl[id].erase(sl[id].begin());
		auto [y, yc] = *sl[id].begin(); sl[id].erase(sl[id].begin());
		sl[id].emplace(x + y + 1, xc + yc);
	}
	/*
	cerr << id << " ";
	for (auto x : sl[id])
		cerr << " " << x;
	cerr << endl;
	*/
}

signed main()
{
	freopen("bird.in", "r", stdin);
	freopen("bird.out", "w", stdout);
	
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int n;
	
	cin >> n;
	fill(hd, hd + n, -1);
	for (int i = 1, x, y; i < n; i++)
	{
		cin >> x >> y, x--, y--;
		add(x, y), add(y, x);
	}
	dfs(0, -1);
	cout << sl[0].begin()->first + bool(sl[0].begin()->second) << endl;
	
	return 0;
}
// started coding at: 06-04 09:23:31